<template>
  <div class="login-container">
    <el-header style="height: 9.2%">
      <div class="logo">
        <img src="../../assets/login_images/logo.png" style="width: 100%;height: 100%"/>
      </div>
      <div class="title">
        <div style="width: 100%;height: 100%;font-size: 20px;text-align: center;vertical-align:middle">区域停车道路管理系统</div>
      </div>
      <div class="sx"></div>
      <div class="login_text">
        <img src="../../assets/login_images/login.png" style="width: 100%;height: 100%"/>
      </div>
    </el-header>
    <el-main>
      <div class="box1"></div>
      <div class="box2"></div>
      <div class="login_formBg"></div>
      <div class="login_form">
        <div class="login_title"></div>
        <el-form class="login-form" autoComplete="on" :model="loginForm" :rules="loginRules" ref="loginForm"
                   label-position="left">
            <el-form-item prop="username">
              <el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" placeholder="在此输入登录名"/>
            </el-form-item>
            <el-form-item prop="password">
                <el-input name="password" :type="passwordType" @keyup.enter.native="handleLogin" v-model="loginForm.password"
                          autoComplete="on" placeholder="请输入密码"/>
              </el-form-item>
                <el-button :loading="loading"
                           @click.native.prevent="handleLogin">登 录
                </el-button>
        </el-form>
      </div>
    </el-main>
    <el-footer>
      <el-row style="text-align: center">
        版权所有：泰华智慧产业集团股份有限公司
      </el-row>
    </el-footer>
  </div>
</template>

<script>
  import LangSelect from '../../components/LangSelect'
  import SocialSign from './socialsignin'

  export default {
    components: { LangSelect, SocialSign },
    data() {
      return {
        loginForm: {
          username: '00005',
          password: '123'
        },
        loginRules: {
          username: [{ required: true, trigger: 'blur', message: '请输入用户名' }],
          password: [{ required: true, trigger: 'blur', message: '请输入密码' }]
        },
        passwordType: 'password',
        loading: false,
        showDialog: false
      }
    },
    methods: {
      showPwd() {
        if (this.passwordType === 'password') {
          this.passwordType = ''
        } else {
          this.passwordType = 'password'
        }
      },
      handleLogin() {
        this.$refs.loginForm.validate(valid => {
          if (valid) {
            this.loading = true
            console.log(valid)
            this.$store.dispatch('LoginByUsername', this.loginForm).then(
              (res) => {
              console.log('nnnnnn')
              this.loading = false
              this.$router.push({ path: '/' })
              },
              (error) =>{
                console.log(error)
              }
            )
          } else {
            console.log('error submit!!')
            return false
          }
        })
      }
    }
  }
</script>
<style rel="stylesheet/scss" lang="scss">
  $bg: #2d3a4b;
  $light_gray: #eee;

  /* reset element-ui css */
  .login-container {
    .el-input {
      display: inline-block;
      height: 46px;
      width: 100%;
      input {
        background: #FFFFFF;
        border: 0px;
        -webkit-appearance: none;
        border-radius: 0px;
        height: 46px;
        &:-webkit-autofill {
          -webkit-box-shadow: 0 0 0px 1000px $bg inset !important;
          -webkit-text-fill-color: #fff !important;
        }
      }
    }
    .el-button{
      display: inline-block;
      width: 100%;
      height: 50px;
      background-color: #3F51B5;
      opacity: 0.9;
      border-radius: 0px;
      color: #FFFFFF;
      font-size: 20px;
      margin-top: 5%;
      font-family: MicrosoftYaHei;
      text-align: center;
      button{
        width: 100%;
        height: 50px;
      }
    }
    .el-form-item {
      background: #FFFFFF;
    }
  }
</style>

<style rel="stylesheet/scss" lang="scss" scoped>
  $bg: #2d3a4b;
  $dark_gray: #889aa4;
  $light_gray: #eee;
  .login-container {
    position: fixed;
    height: 100%;
    width: 100%;
    background-color: #fff;
  }
  .el-header{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 9.2%;
    margin: 0;
    border: none;
    background-color: #fff;
    .logo{
      position: absolute;
      width: 4.4%;
      height: 85%;
      bottom: 0;
      left: 19.1%;
    }
    .title{
      position: absolute;
      width: 19%;
      height: 41%;
      left: 24.1%;
      bottom: 27%;
    }
    .sx{
      position: absolute;
      width: 0.1%;
      height: 27.5%;
      left: 44.6%;
      bottom: 33%;
      background-color: #E1E1E1;
    }
    .login_text{
      position: absolute;
      width: 2.5%;
      height: 33%;
      bottom: 29%;
      left: 45.5%;
    }
  }
  .el-main{
    position: absolute;
    width: 100%;
    height: 49.7%;
    left: 0;
    top: 9.2%;
    margin: 0;
    z-index: 0;
    background: url("../../assets/login_images/bg.png") no-repeat;
    -webkit-background-size: 100% 100%;
    background-size: 100% 100%;
    .box1{
      width: 100%;
      height: 100%;
      z-index: 1;
      background: url("../../assets/login_images/picture1.png") no-repeat;
      -webkit-background-size: 100% 100%;
      background-size: 100% 100%;
    }
    .box2{
      width: 18%;
      height: 20%;
      z-index: 2;
      position: absolute;
      top: 14%;
      left: 25%;
      background: url("../../assets/login_images/mainText.png") no-repeat;
      -webkit-background-size: 100% 100%;
      background-size: 100% 100%;
    }
    .login_formBg{
      position: absolute;
      top: 14%;
      left: 56.5%;
      width: 20.4%;
      height: 71%;
      z-index: 2;
      background: #FFFFFF;
      opacity: 0.8;
    }
    .login_form{
      position: absolute;
      top: 14%;
      left: 56.5%;
      width: 20.4%;
      height: 71%;
      z-index: 3;
      background: transparent;
      box-shadow: 0 0 4px 2px;
      .login_title{
        width: 19%;
        height: 5.3%;
        position: absolute;
        top: 8.4%;
        left: 8.2%;
        background: url("../../assets/login_images/passLogin.png") no-repeat;
        -webkit-background-size: 100% 100%;
        background-size: 100% 100%;
      }
      .el-form{
        width: 84%;
        height: 56%;
        position: absolute;
        left: 8.2%;
        right: 8.2%;
        top: 28%;
      }

    }
  }
  .el-footer{
    width: 33%;
    position: absolute;
    top: 70.1%;
    left: 33.6%;
    right: 33.5%;
    font-family: MicrosoftYaHei;
    font-size: 13px;
    color: rgba(0,0,0,0.54);
  }
</style>
